//
//  MainViewController.swift
//  新浪微博
//
//  Created by 孙宏毅 on 16/6/2.
//  Copyright © 2016年 孙宏毅. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
//        self.addChileController()
        self.addController()
        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func addChileController(controller:UIViewController,iconName:String,title:String)
    {
        let navigationHome = UINavigationController(rootViewController: controller)
        controller.title = title
        controller.tabBarItem.image = UIImage(named: iconName)
        controller.tabBarItem.selectedImage = UIImage(named: "\(iconName)_selected")
        addChildViewController(navigationHome)
    }
    
    func addController()
    {
        let home = HomeViewController()
        self.addChileController(home, iconName: "tabbar_home", title: "首页")
        
        let Descovery = DescoveryViewController()
        self.addChileController(Descovery, iconName: "tabbar_discover", title: "发现")
        
        let Message = MessageViewController()
        self.addChileController(Message, iconName: "tabbar_message_center", title: "消息")
        
        let Profile = ProfileViewController()
        self.addChileController(Profile, iconName: "tabbar_profile", title: "我的")
        
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
